<template>
    <Layout style="height: 100%" class="main">
        <Header>
            <Menu mode="horizontal" theme="dark" active-name="1">
                <div class="logo-v3">
                    <img :src="logoTime" class="hd-img-responsive"/>
                </div>
                <div class="back-v3">
                  <div class="login-info">
                    <div class="user-info">
                      <span>{{personData.name}}</span>
                      <span> [{{personData.company_name}}] </span>
                    </div>
                  </div>
                  <div class="scroll-info">
                    <!-- <TransitionNotice>
                    </TransitionNotice> -->
                    <div class="textTitle">
<!--                      <span>通知公告:</span>-->
                    </div>
                    <div class="textBox">
                      <transition name="slide">
                        <p class="text line-limit-length" :key="text.id" @click="hreftwo">{{text.val}}</p>
                      </transition>
                    </div>
                    <!-- <scroll-ad :dataList = "adList" hover-color="#b4a078" inhover-color="#ffffff" id="aaa"></scroll-ad> -->
                  </div>
                  <div class="login-btn">
<!--                    <div class="logout-btn logout-btn-item" @click="deviceBinding2()">-->
<!--                      <Icon type="ios-call"/>-->
<!--                      客服服务-->
<!--                      &lt;!&ndash; :17642057151、17640241887、13324056283 &ndash;&gt;-->
<!--                    </div>-->
<!--                    <div class="logout-btn logout-btn-item" @click="deviceBinding1()">-->
<!--                      <Icon type="ios-cloud-download-outline"/>-->
<!--                      下载中心-->
<!--                    </div>-->
<!--                    <div class="logout-btn logout-btn-item" @click="deviceBinding()">-->
<!--                        <Icon type="ios-laptop"/>-->
<!--                        设备绑定-->
<!--                    </div>-->
                    <!-- <div class="logout-btn logout-btn-item" @click="showErcode(codeUrl)">
                        <Icon type="md-key"/>
                        绑定
                    </div> -->
<!--                    <div class="logout-btn logout-btn-item" @click="passwordInfo.show=true">-->
<!--                        <Icon type="md-create"/>-->
<!--                        修改密码-->
<!--                    </div>-->
                    <div class="logout-btn logout-btn-item" @click="logout">
                        <Icon type="md-log-out"/>
                        注销
                    </div>
                  </div>
                </div>
              <Modal v-model="modalDevice1" title="下载中心" width="700"
                     style="position:relative;">
                <div style="line-height:25px">
                  <div style="font-size: 14px;color: #2E2D3C;font-weight: bold;margin-bottom: 20px">设备驱动下载</div>
                      <div >捷宇高拍仪
                      </div>
                      <div>良田高拍仪
                        <a style="margin-right: 50px;margin-left: 50px" href="https://pan.baidu.com/s/1Sp7a4Mw3BU-4stZM-zRJOA" target="_blank">https://pan.baidu.com/s/1Sp7a4Mw3BU-4stZM-zRJOA</a>
                        <span>提取码：qfsi</span></div>
                      <div>紫图高拍仪
                        <a style="margin-right: 35px;margin-left: 50px" href="https://pan.baidu.com/s/1CM7b4_EiRI33HkuByBjuCw" target="_blank">https://pan.baidu.com/s/1CM7b4_EiRI33HkuByBjuCw</a>
                        <span>提取码：6hso</span></div>
                      <div>德意拍高拍仪
                        <a style="margin-right: 60px;margin-left: 40px" href="https://pan.baidu.com/s/1RMOLv2xXtwqh8pCFfFSrtA" target="_blank">https://pan.baidu.com/s/1RMOLv2xXtwqh8pCFfFSrtA</a>
                        <span>提取码：8mzs</span>
                      </div>
                      <div>维山高拍仪
                        <a style="margin-right: 60px;margin-left: 40px" href="https://pan.baidu.com/s/1ee3QkVNVP4xJskVsOgnvFA" target="_blank">https://pan.baidu.com/s/1ee3QkVNVP4xJskVsOgnvFA</a>
                        <span>提取码：saw4</span>
                      </div>
                      <div>点易拍高拍仪</div>
                </div>
                <Divider/>
                <div style="line-height:25px">
                  <div style="font-size: 14px;color: #2E2D3C;font-weight: bold;margin-bottom: 20px">培训视频下载</div>
                  <div>视频
                    <a style="margin-right: 50px;margin-left: 90px" href="https://pan.baidu.com/s/1vSMpSicWSTuLqVa5i2173g" target="_blank">https://pan.baidu.com/s/1vSMpSicWSTuLqVa5i2173g</a>
                    <span>提取码：lj2w</span>
                  </div>
                </div>
              </Modal>
                <Modal v-model="modalDevice" title="选择该社区使用的设备" width="500" cancel-text="关闭"
                           @on-ok="saveDevice()" @on-cancel="modalDevice = false" ok-text="确定"
                           style="position:relative;">
                        <div style="display: table-caption; line-height:25px">
                            <RadioGroup v-model="highMeter1">
                                <Radio label="JieYuDevice">
                                    <span>捷宇高拍仪</span>
                                </Radio>
                                <Radio label="LiangTianDevice">
                                    <span>良田高拍仪</span>
                                </Radio>
                                <Radio label="ZiTuDevice">
                                    <span>紫图高拍仪</span>
                                </Radio>
                                <Radio label="DeYiPaiDevice">
                                    <span>德意拍高拍仪</span>
                                </Radio>
                                <Radio label="WeiShanDevice">
                                    <span>维山高拍仪</span>
                                </Radio>
                                <Radio label="DianYiPaiDevice">
                                  <span>点易拍高拍仪</span>
                                </Radio>
                            </RadioGroup>
                        </div>
                    </Modal>
                    <Modal v-model="modalDevice2" width="900"
                     style="position:relative;">
                     <div style="padding:50px" v-html="modalDevice2html">
                    </div>
                  <Divider/>
              </Modal>
              <!-- <Modal v-model="modalDevice3" title="关于“全市通办”客服服务管理的说明" width="700"
                     style="position:relative;">
                  <Divider/>
              </Modal> -->
              <Modal v-model="display_model1_obj1.modal1" width="900" :mask-closable="false">
                <div style="padding:50px" v-html="display_model1_obj1.html">
                </div>
                <div slot="footer">
                    <Button type="primary" :disabled="!disabledCodeBtn" @click="savelogea">{{time}}确认</Button>
                </div>
              </Modal>
                <Modal v-model="modalQr" title="二维码" width="500" cancel-text="关闭"
                        @on-ok="modalQr = false" @on-cancel="modalQr = false" ok-text="确定"
                        style="position:relative;">
                    <div id="qrcode" ref="qrcode" style="margin-left: 18%"></div>
                    <div style="text-align: center;margin-top: 10px;font-size: 1rem;">扫描二维码绑定用户信息</div>
                </Modal>
            </Menu>
        </Header>
        <Layout>
            <Modal v-model="display_model1_obj.modal1" :title="display_model1_obj.text" width="900">
                <div id="printMe">
                    <Form label-position="right" :label-width="100">
                        <Row>
                            <Col span="24" class="ivu-form-item-content" style="text-align: center">
                                <embed width="800" v-show="display_model1_obj.modal1" height="600"
                                       :src="display_model1_obj.filepath"></embed>
                            </Col>
                        </Row>
                    </Form>
                </div>
                <div slot="footer">
                    <!-- <Button type="success" size="large" v-print="'#printMe'">打印</Button> -->
                    <Button type="error" size="large" @click="display_model1_obj.modal1=false">关闭</Button>
                </div>
            </Modal>
            <Modal v-model="passwordInfo.show" title="修改密码" width="600" :closable="false" :mask-closable="false">
                <Form label-position="right" :label-width="100" ref="passwordInfo" :model="passwordInfo"
                      :rules="ruleInline">
                    <FormItem prop="oldpassword" label="旧密码：" class="set-password-input">
                        <Input type="password" v-model="passwordInfo.oldpassword"></Input>
                    </FormItem>
                    <FormItem prop="newpassword" label="新密码：" class="set-password-input">
                        <Input type="password" v-model="passwordInfo.newpassword"></Input>
                    </FormItem>
                    <FormItem prop="repassword" label="确认密码：" class="set-password-input">
                        <Input type="password" v-model="passwordInfo.repassword"></Input>
                    </FormItem>
                    <Row>
                    <Col span="16" offset='4' class="ivu-form-item-label">密码建议由数字、字符和字母组成，必须8位（包括8位）以上</Col>
                    </Row>
                </Form>
                <div slot="footer">
                    <Button type="success" size="large" @click="setPassWord('passwordInfo')">确认</Button>
                    <Button type="error" size="large" @click="closePassWord('passwordInfo')">关闭</Button>
                </div>
            </Modal>
            <Sider hide-trigger  collapsible :width="256" :collapsed-width="64"
                   v-model="collapsed"
                   class="left-sider"
                   :style="{overflow: 'hidden',maxHeight: maxH+'px'}">
                <yiqing-menu :menu-list="minZhengMenus" @on-select="openPage" ref="sideMenu" :active-name="$route.name" :collapsed="collapsed"></yiqing-menu>
                <!-- <three-menu v-if="!reloadItem" :menu-list="treeDataList" @on-select="viewProcess"></three-menu> -->
            </Sider>
<!--            <Sider hide-trigger v-show="!hiddenLeftMenus && !hiddenLeftSystemMenus" collapsible :width="256" :collapsed-width="64"-->
<!--                   v-model="collapsed"-->
<!--                   class="left-sider"-->
<!--                   :style="{overflow: 'hidden',maxHeight: maxH+'px'}">-->
<!--                <yiqing-menu :menu-list="yiQingMenus" @on-select="openPage" ref="sideMenu1" :active-name="$route.name"></yiqing-menu>-->
<!--            </Sider>-->
<!--            <Sider hide-trigger v-show="!hiddenLeftMenus && hiddenLeftSystemMenus" collapsible :width="256" :collapsed-width="64"-->
<!--                   v-model="collapsed"-->
<!--                   class="left-sider"-->
<!--                   :style="{overflow: 'hidden',maxHeight: maxH+'px'}">-->
<!--                <yiqing-menu :menu-list="systemSetUpMenus" @on-select="openPage"></yiqing-menu>-->
<!--            </Sider>-->
            <Layout class="content-layout-v3" :style="{overflow: 'hidden',maxHeight: maxH+'px',overflowY:'scroll'}">
<!--                <div class="tag-nav-wrapper">-->
<!--                  <tags-nav :value="$route" @input="handleClick" :list="tagNavList" @on-close="handleCloseTag"/>-->
<!--                </div>-->
                <Content :style="{padding: '15px', background: '#fff'}">
                    <keep-alive :include="cacheList">
                      <router-view/>
                    </keep-alive>
                    <!-- <router-view></router-view> -->
                </Content>
            </Layout>
        </Layout>
    </Layout>
</template>

<script>
import './index.less'
// import logoTime from '@/assets/images/logo_qstb.png'
import logoTime from '@/assets/images/head_bg.jpg'
import { mapMutations, mapActions, mapGetters } from 'vuex'
import { updatePwd } from '@/api/user'
import { setSeparateNotice, treelist, mzMenulist, findHtmlList, savelog } from '@/api/eventlist'
import ThreeMenu from './three-menu'
import device from '@/view/demo/device'
import { clearInterval } from 'timers'
import QRCode from 'qrcodejs2'
import { updateUserGPY } from '@/api/common'
import { releaseNoticeList } from '@/api/mainv3'
import YiqingMenu from '@/view/xian-page/indexv3/yiqing-menu/yiqing-menu'
import TagsNav from '@/components/main/components/tags-nav'
import { getNewTagList, routeEqual, getMenuByRouter, localSave, localClear } from '@/libs/util'
import { getRouterReq } from '@/api/routers'
import routers from '@/router/routers'
import Gmk from '@/view/login/Gmk.vue'
// import { mzMenulist } from '@/api/yi-qing-fang-kong'
// import TransitionNotice from '@/components/transition-notice/index'
// import scrollAd from '@/components/scrollAd'
// import $ from 'jquery'
export default {
  name: 'indexv3',
  components: {
    YiqingMenu,
    ThreeMenu,
    device,
    TagsNav
    // TransitionNotice
    // scrollAd
  },
  data () {
    const validatePassCheck = (rule, value, callback) => {
      if (value !== this.passwordInfo.newpassword) {
        callback(new Error('确认密码与新密码不相同'))
      } else {
        callback()
      }
    }
    const validatePassCheck1 = (rule, value, callback) => {
      var pwdRegex = new RegExp('(?=.*[0-9]).{8,30}')
      var pwdRegex1 = new RegExp('(?=.*[a-zA-Z]).{8,30}')
      var pwdRegex2 = new RegExp('(?=.*[^a-zA-Z0-9]).{8,30}')
      if (!pwdRegex.test(value)) {
        alert('您的密码复杂度太低（密码中必须包含数字），请及时修改密码！')
      } else if (!pwdRegex1.test(value)) {
        alert('您的密码复杂度太低（密码中必须包含字母），请及时修改密码！')
      } else if (!pwdRegex2.test(value)) {
        alert('您的密码复杂度太低（密码中必须包含特殊字符），请及时修改密码！')
      } else {
        callback()
      }
    }
    return {
      device_code: '', // 高拍仪参数
      highMeter1: '', // 高拍仪
      highMeter2: '', // 高拍仪
      highMeter3: '', // 高拍仪
      type: '',
      shuju: [],
      codeUrl: '',
      company_codes: '',
      loginCompanyType: '1', // 登录账号类型 1城市 2农村
      loginNames: '',
      modalDevice: false,
      modalDevice1: false,
      modalDevice2: false,
      modalDevice3: true,
      disabledCodeBtn: false,
      htmllist: [],
      time: '',
      display_model1_obj1: { modal1: false, filepath: '', html: '' },
      modalDevice2html: '',
      modalQr: false,
      timerInterval: null,
      collapsed: false,
      reloadItem: false,
      logoTime,
      totalItemNum: 0,
      totalBMNum: 0,
      treeDataList: [],
      searchName: '',
      personData: {},
      routeList: [],
      passwordInfo: { show: false },
      display_model1_obj: { modal1: false, filepath: '' },
      maxH: `${document.documentElement.clientHeight}` - 166,
      ruleInline: {
        oldpassword: [
          { required: true, message: '请填写旧密码', trigger: 'blur' }
        ],
        newpassword: [
          { required: true, message: '新密码不能为空', trigger: 'blur' },
          { type: 'string', min: 8, message: '密码长度不能少于8位', trigger: 'blur' },
          { validator: validatePassCheck1, trigger: 'blur' }
        ],
        repassword: [
          { required: true, message: '请填写确认密码', trigger: 'blur' },
          { type: 'string', min: 8, message: '密码长度不能少于8位', trigger: 'blur' },
          { validator: validatePassCheck, trigger: 'blur' }
        ]
      },
      yiQingMenus: [],
      minZhengMenus: [],
      adList: [
        // { content: '全科社工们，系统喊你快来试用', ink: 'xx.com' }
      ],
      location_url: '',
      textArr: [],
      number: 0,
      tempTagNavList: [],
      login_url: ''
    }
  },
  computed: {
    text () {
      return {
        id: this.number,
        val: this.textArr[this.number]
      }
    },
    // menuList () {
    //   return this.treeDataList
    // },
    // hiddenLeftMenus () {
    //   // if (this.$common.xeUtils.arrayIndexOf(['yiQingStreetExportList', 'yiQingSuperiorList', 'yiQingAddInOut', 'yiQingMoveOutList', 'yiQingMoveInList', 'yiQingAreaWarning', 'yiQingList', 'yiQingAdd', 'yiQingStatistics', 'yiQingStatisticsEpidemic', 'yiQingFeverList', 'yiQingAddButtons', 'yiQingEpidemicList', 'yiQingQrCode', 'yiQingFeverNotList', 'yiQingMobileTerminalList', 'yiQingFeverMobileList', 'yiQingSuperiorVillageList', 'yiQingAddApp', 'yiQingShenAppDataList', 'yiQingCityAppDataList', 'yiQingAddCitys', 'yiQingForeignPersonList', 'mainv3'], this.$route.name) !== -1) {
    //   //   return false
    //   // } else {
    //   //   return true
    //   // }
    //   if (this.$common.xeUtils.arrayIndexOf(['mainv3', 'workbench', 'separateservice', 'message', 'item', 'closingratelist', 'grid', 'telnote', 'knowledgebase', 'itemlist', 'handinformation', 'question', 'dailyrecord', 'agentreservation', 'activitymanagement', 'apply_disabled_allowance', 'gridmaintain', 'house_handinformation', 'subsistenceapplication', 'subsistenceapplication1', 'subsistenceapplication2', 'expenditurelist', 'supportlist', 'basicproperty', 'houseproperty', 'workunit', 'educationinfo', 'nearfamily', 'submitinfo', 'stopinsurance', 'deathstop', 'transregionalmigration', 'transferacceptance', 'specialrelief', 'tworescues', 'heatingassistance', 'acceptancenotice', 'matterslist', 'matterssynchronization', 'shequ-jiedao-list', 'tk_subsistenceapplication', 'tk_subsistenceapplication1', 'tk_subsistenceapplication2'], this.$route.name) !== -1) {
    //   //  console.log('1'+true)
    //     return true
    //   } else {
    //     // console.log('1'+false)
    //     return false
    //   }
    // },
    // hiddenLeftSystemMenus () {
    //   if (this.$common.xeUtils.arrayIndexOf(['/systemSetupArea', '/systemSetupUser', '/systemSetupOffice'], this.$route.name) !== -1) {
    //     // console.log('2'+true)
    //     return true
    //   } else {
    //     // console.log('2'+false)
    //     return false
    //   }
    // },
    ...mapGetters([
      'errorCount'
    ]),
    tagNavList () {
      return this.$store.state.app.tagNavList
    },
    tagRouter () {
      return this.$store.state.app.tagRouter
    },
    userAvator () {
      return this.$store.state.user.avatorImgPath
    },
    cacheList () {
      const list = ['ParentView', ...this.tagNavList.length ? this.tagNavList.filter(item => !(item.meta && item.meta.notCache)).map(item => item.name) : []]
      return list
    },
    // menuList () {
    //   return this.$store.getters.menuList
    // },
    local () {
      return this.$store.state.app.local
    },
    hasReadErrorPage () {
      return this.$store.state.app.hasReadErrorPage
    },
    unreadCount () {
      return this.$store.state.user.unreadCount
    }
  },
  methods: {
    hreftwo () {
      this.$router.push({ path: '/message' })
    },
    startMove () {
      // eslint-disable-next-line
      let timer = setTimeout(() => {
        if (this.number === this.textArr.length) {
          this.number = 0
        } else {
          this.number += 1
        }
        this.startMove()
      }, 2500) // 滚动不需要停顿则将2000改成动画持续时间
    },
    ...mapActions([
      'handleLogOut'
    ]),
    mzMenulist () {
      let menu_id = 'abf84050-12ca-11eb-b210-0242ac11000f'
      mzMenulist(menu_id).then(ret => {
        if (ret.data.errcode === 0) {
          this.minZhengMenus = ret.data.data.list
          this.minZhengMenus.unshift(
            { name: '首页',
              type_id: 20001,
              icon: 'md-home',
              path: '/mainv3' }
          )
        }
      })
    },
    logout () {
      this.handleLogOut().then(() => {
        clearInterval(this.timerInterval)
        localClear()
        // this.token = localStorage.getItem('token')
        // localStorage.setItem('token', this.token)
        if (this.login_url.indexOf('http://qstb') !== -1) {
          window.open('http://qstb.mzj.shenyang.gov.cn/#/login')
        } else { // 生产环境
          this.$router.push({ name: 'login' })
        }
      })
    },
    closePassWord (name) {
      this.passwordInfo.show = false
      this.$refs[name].resetFields()
    },
    setPassWord (name) {
      this.$refs[name].validate((valid) => {
        if (valid) {
          updatePwd(this.passwordInfo).then(res => {
            if (res.data.data) {
              this.$Notice.success({ title: '修改成功', desc: '修改密码后需要重新登录' })
              this.passwordInfo.show = false
              this.logout()
            } else {
              this.$Notice.error({ title: '修改失败', desc: res.data.errmsg })
            }
          })
        } else {
          this.$Notice.error({ title: '信息错误', desc: '密码修改信息错误，请重新填写' })
        }
      })
    },
    viewProcess (item) {
      if (item.file_url) {
        this.display_model1_obj.text = item.type_name
        this.display_model1_obj.modal1 = true
        this.display_model1_obj.filepath = item.file_url
      } else {
        this.$Notice.error({ title: '无文件', desc: '当前事项无PDF说明文档' })
      }
    },
    openPage (item) {
      if (item.path) {
        this.$router.push({ path: item.path })
      } else if (item.link) {
        window.open(item.link)
      } else {
        this.$Notice.error({ title: '无文件', desc: '等待添加路径' })
      }
    },
    searchList1 () {
      if (!this.searchName) {
        this.searchList()
      }
    },
    searchList () {
      this.reloadItem = true
      this.treeDataList.forEach(e1 => {
        e1.hidden = true
        if (e1.children) {
          let curNum1 = 0
          e1.children.forEach(e2 => {
            if (e2.children) {
              let curNum2 = 0
              e2.children.forEach(e3 => {
                e3.hidden = true
                if (e3.type_name.indexOf(this.searchName) >= 0) {
                  e3.hidden = false
                  curNum2++
                  curNum1++
                }
              })
              e2.hidden = true
              if (curNum2 > 0) {
                e2.count = curNum2
                e2.hidden = false
              }
            } else {
              e2.hidden = true
              if (e2.type_name.indexOf(this.searchName) >= 0) {
                e2.hidden = false
                curNum1++
              }
            }
          })
          if (curNum1 > 0) {
            e1.count = curNum1
            e1.hidden = false
          }
        } else {
          if (!this.searchName) {
            e1.hidden = false
          }
        }
      })
      this.$nextTick(() => {
        this.reloadItem = false
      })
    },
    changeRoute (index) {
      this.routeList.forEach(element => {
        element.state = false
      })
      this.routeList[index].state = true
    },
    getTreeList () {
      treelist().then(ret => {
        let result = ret.data.data
        this.treeDataList = result
        this.treeDataList.forEach(element => {
          element.count = element.count || 0
          if (element.children) {
            this.totalBMNum += 1
            element.children.forEach(e2 => {
              if (e2.children) {
                e2.count = e2.children.length || 0
                element.count += e2.count
              }
            })
            element.count = element.count || element.children.length
          }
          this.totalItemNum += element.count
        })
      })
    },
    showErcode (codeUrl) {
      // let qrcodeEL = document.getElementById('qrcode')
      // let qrcode = new QRCode(qrcodeEL)
      document.getElementById('qrcode').innerHTML = ''
      this.modalQr = true
      this.getCode(codeUrl)
      // qrcode.clear() // clear the code.
      // qrcode.makeCode(codeUrl) // make another code.
    },
    getCode (codeUrl) {
      var qrcode = new QRCode(document.getElementById('qrcode'), {
        text: codeUrl,
        top: 200,
        width: 300,
        height: 300,
        colorDark: '#000000',
        colorLight: '#ffffff',
        correctLevel: QRCode.CorrectLevel.H
      })
      return qrcode
    },
    // 驱动下载
    deviceBinding1 () {
      console.log('设备绑定')
      this.modalDevice1 = true
    },
    // 设备绑定
    deviceBinding () {
      console.log('设备绑定')
      this.modalDevice = true
    },
    // 客服电话
    deviceBinding2 () {
      console.log('客服电话')
      this.modalDevice2 = true
    },
    saveDevice () {
      updateUserGPY({ device_code: this.highMeter1 }).then(res => {
        if (res.data.errcode === 0) {
          this.$Notice.success({ title: '设备绑定成功', desc: '设备绑定成功，请注销重新登录' })
        } else {
          this.$Notice.error({ title: '绑定失败', desc: res.data.errmsg })
        }
      })
      this.$store.state.user.highMeter = this.highMeter1
    },
    // // LM总账号显示管理菜单，其他账号不显示
    // permission_display () {
    //   if (this.company_codes !== 'LM') {
    //     let tempList = []
    //     this.routeList.forEach(element => {
    //       if (element.path === '/itemoption' || element.path === '/activitymanagement') {
    //       } else {
    //         tempList.push(element)
    //       }
    //     })
    //     this.routeList = tempList
    //   }
    // },
    // // 不同类型账号菜单过滤
    // loginCode_display () {
    //   console.log(this.loginCompanyType, '账号类型')
    //   if (this.company_codes === 'LM') {
    //     // LM总账号过滤【村统计管理】菜单
    //     this.yiQingMenus.splice(5, 1)
    //     this.yiQingMenus.push(
    //       {
    //         type_name: '集中隔离',
    //         type_id: 20011,
    //         icon: 'ios-create-outline',
    //         children: [
    //           {
    //             type_name: '新增',
    //             path: '/yi-qing/add-jz',
    //             icon: 'ios-add-circle-outline',
    //             type_id: 2001101
    //           }, {
    //             type_name: '列表',
    //             path: '/yi-qing/list-jz',
    //             icon: 'ios-list',
    //             type_id: 2001102
    //           }, {
    //             type_name: '统计分析',
    //             path: '/yi-qing/superior-list',
    //             icon: 'ios-list',
    //             type_id: 2001103
    //           }
    //           // {
    //           //   type_name: '记录',
    //           //   path: '/yi-qing/superior-list-jz',
    //           //   icon: 'ios-list',
    //           //   type_id: 2001104
    //           // }
    //         ] }
    //     )
    //   } else if (this.company_codes === 'LM20927') {
    //     // LM20927为集中安置点账号，只显示[集中安置点]菜单
    //     // let tempList = this.yiQingMenus
    //     // this.yiQingMenus = [tempList[3]]
    //     this.yiQingMenus = []
    //     this.minZhengMenus = []
    //     this.systemSetUpMenus = []
    //   } else if (this.accountList.includes(this.loginNames)) {
    //     this.yiQingMenus = [
    //       {
    //         type_name: '首页',
    //         type_id: 20001,
    //         icon: 'md-home',
    //         path: '/mainv3',
    //         count: 12
    //       }, {
    //         type_name: '集中隔离',
    //         type_id: 20011,
    //         icon: 'ios-create-outline',
    //         children: [
    //           {
    //             type_name: '新增',
    //             path: '/yi-qing/add-jz',
    //             icon: 'ios-add-circle-outline',
    //             type_id: 2001101
    //           }, {
    //             type_name: '列表',
    //             path: '/yi-qing/list-jz',
    //             icon: 'ios-list',
    //             type_id: 2001102
    //           }
    //         ],
    //         count: 12
    //       }]
    //     this.minZhengMenus = [
    //       {
    //         type_name: '首页',
    //         type_id: 30001,
    //         icon: 'md-home',
    //         path: '/mainv3',
    //         count: 12
    //       },
    //       {
    //         type_name: '疫情防控',
    //         type_id: 30012,
    //         icon: 'md-bug',
    //         path: '/yi-qing/statistics',
    //         count: 4
    //       }]
    //   } else if (this.loginNames === 'LM000012' || this.loginNames === 'LM000022' || this.loginNames === 'LM000052' || this.loginNames === 'LM000043' || this.loginNames === 'LM000033' || this.loginNames === 'LM000063' || this.loginNames === 'LM000072' || this.loginNames === 'LM000083' || this.loginNames === 'LM000092' || this.loginNames === 'LM000102' || this.loginNames === 'LM000132' || this.loginNames === 'LM000122' || this.loginNames === 'LM000113') {
    //     this.yiQingMenus = [
    //       {
    //         type_name: '首页',
    //         type_id: 20001,
    //         icon: 'md-home',
    //         path: '/mainv3',
    //         count: 12
    //       }, {
    //         type_name: '集中隔离',
    //         type_id: 20011,
    //         icon: 'ios-create-outline',
    //         children: [
    //           {
    //             type_name: '新增',
    //             path: '/yi-qing/add-jz',
    //             icon: 'ios-add-circle-outline',
    //             type_id: 2001101
    //           }, {
    //             type_name: '列表',
    //             path: '/yi-qing/list-jz',
    //             icon: 'ios-list',
    //             type_id: 2001102
    //           }, {
    //             type_name: '统计分析',
    //             path: '/yi-qing/superior-list',
    //             icon: 'ios-list',
    //             type_id: 2001103
    //           }
    //         ],
    //         count: 12
    //       }]
    //     this.minZhengMenus = [
    //       {
    //         type_name: '首页',
    //         type_id: 30001,
    //         icon: 'md-home',
    //         path: '/mainv3',
    //         count: 12
    //       },
    //       {
    //         type_name: '疫情防控',
    //         type_id: 30012,
    //         icon: 'md-bug',
    //         path: '/yi-qing/statistics',
    //         count: 4
    //       }]
    //   } else if (this.loginNames === 'LM40001' || this.loginNames === 'LM400011') {
    //     this.yiQingMenus = [
    //       {
    //         type_name: '首页',
    //         type_id: 20001,
    //         icon: 'md-home',
    //         path: '/mainv3',
    //         count: 12
    //       }, {
    //         type_name: '疫情人员',
    //         type_id: 20011,
    //         icon: 'ios-create-outline',
    //         children: [
    //           {
    //             type_name: '列表',
    //             path: '/yi-qing/list-wj',
    //             icon: 'ios-list',
    //             type_id: 2001102
    //           }
    //         ],
    //         count: 12
    //       }]
    //     this.minZhengMenus = [
    //       {
    //         type_name: '首页',
    //         type_id: 30001,
    //         icon: 'md-home',
    //         path: '/mainv3',
    //         count: 12
    //       },
    //       {
    //         type_name: '疫情防控',
    //         type_id: 30012,
    //         icon: 'md-bug',
    //         path: '/yi-qing/statistics',
    //         count: 4
    //       }]
    //   } else if (this.loginNames === 'LM40002') {
    //     this.minZhengMenus =
    //       [
    //         {
    //           type_name: '首页',
    //           type_id: 30001,
    //           icon: 'md-home',
    //           path: '/mainv3',
    //           count: 12
    //         },
    //         {
    //           type_name: '客服功能',
    //           type_id: 20011,
    //           icon: 'ios-create-outline',
    //           children: [
    //             {
    //               type_name: '疫情人员信息管理',
    //               path: '/kefupage/edit',
    //               icon: 'md-cafe',
    //               type_id: 2001101
    //             },
    //             {
    //               type_name: '账号重置',
    //               path: '/kefupage/reset-account',
    //               icon: 'md-refresh',
    //               type_id: 2001101
    //             }
    //           ]
    //         }
    //       ]
    //     this.yiQingMenus = this.minZhengMenus
    //   } else if ((this.loginNames === 'LM000011' || this.loginNames === 'LM000021' || this.loginNames === 'LM000031' || this.loginNames === 'LM000042' || this.loginNames === 'LM000051' || this.loginNames === 'LM000062' || this.loginNames === 'LM000071' || this.loginNames === 'LM000082' || this.loginNames === 'LM000091' || this.loginNames === 'LM000101' || this.loginNames === 'LM000111' || this.loginNames === 'LM000121' || this.loginNames === 'LM000131') && this.loginCompanyType === '1') {
    //     // 村管理账号只保留【村排查】和【村统计列表】两个菜单
    //     // this.yiQingMenus.splice(0, 1)
    //     // this.yiQingMenus.splice(2, 1)
    //     // this.yiQingMenus.splice(3, 1)
    //     // this.yiQingMenus.splice(4, 1)
    //     // this.yiQingMenus.splice(5, 1)
    //     // this.yiQingMenus.splice(6, 1)
    //     // this.yiQingMenus.splice(7, 1)
    //     let tempList = this.yiQingMenus
    //     this.yiQingMenus = [tempList[0], tempList[2], tempList[5]]
    //     this.minZhengMenus.splice(5, 1)
    //     console.log(this.yiQingMenus, '123123')
    //   } else if (this.loginCompanyType === '2') {
    //     // 农村账号，在菜单中删除[社区排查][集中安置点][移动端管理]菜单
    //     // this.yiQingMenus.splice(0, 1)
    //     // this.yiQingMenus.splice(1, 1)
    //     // this.yiQingMenus.splice(4, 1)
    //     this.yiQingMenus.splice(5, 3)
    //     this.minZhengMenus.splice(5, 1)
    //   } else if (this.loginCompanyType === '1' && this.loginNames !== 'LM000011' && this.loginNames !== 'LM000021' && this.loginNames !== 'LM000031' && this.loginNames !== 'LM000042' && this.loginNames !== 'LM000051' && this.loginNames !== 'LM000062' && this.loginNames !== 'LM000071' && this.loginNames !== 'LM000082' && this.loginNames !== 'LM000091' && this.loginNames !== 'LM000101' && this.loginNames !== 'LM000111' && this.loginNames !== 'LM000121' && this.loginNames !== 'LM000131') {
    //     // console.log(this.company_codes, 'fdsfadsfa')
    //     // 城市账号，在菜单中删除[村排查][集中安置点][移动端管理]菜单
    //     // this.yiQingMenus.splice(1, 2)
    //     // this.yiQingMenus.splice(4, 1)
    //     this.yiQingMenus.splice(5, 3)
    //     this.minZhengMenus.splice(5, 1)
    //   }
    // },
    setFlowSee (id) {
      setSeparateNotice(id).then(res => {
      })
    },
    toSeparate () {
      let router = this.$store.state.app.mainv3Nav
      router.forEach(element => {
        element.state = false
      })
      router[2].state = true
      this.$router.push({
        name: 'separateservice',
        params: { tabindex: 1 }
      })
    },
    ...mapMutations([
      'setBreadCrumb',
      'setTagNavList',
      'addTag',
      'setLocal',
      'setFirstMenuId',
      'setHomeRoute',
      'closeTag'
    ]),
    ...mapActions([
      'handleLogin',
      'getUnreadMessageCount',
      'getAjaxRouterData'
    ]),
    turnToPage (route) {
      // console.log(route, 'main/turnToPage')
      let { name, params, query } = {}
      if (typeof route === 'string') name = route
      else {
        name = route.name
        params = route.params
        query = route.query
      }
      if (name.indexOf('isTurnByHref_') > -1) {
        window.open(name.split('_')[1])
        return
      }
      this.$router.push({
        name,
        params,
        query
      })
    },
    handleCollapsedChange (state) {
      this.collapsed = state
    },
    handleCloseTag (res, type, route) {
      if (type !== 'others') {
        if (type === 'all') {
          this.turnToPage(this.$config.homeName)
        } else {
          if (routeEqual(this.$route, route)) {
            this.closeTag(route)
          }
        }
      }
      this.setTagNavList(res)
    },
    handleClick (item) {
      // console.log(item, '执行main/handleClick')
      this.turnToPage(item)
    },
    getRouterListData () {
      getRouterReq('222').then(res => {
        let listData = getMenuByRouter(res.data, 'admin')
        this.menuList001 = listData
      })
    },
    groupMenuSelect (id, menusData) {
      // this.setFirstMenuId(id)
      localSave('first-menus-data', JSON.stringify(menusData))
      this.$store.dispatch('getAjaxRouterData', id)
    },
    // getNoticeList () {
    //   this.textArr = []
    //   releaseNoticeList({}).then(res => {
    //     if (res.data.errcode === 0) {
    //       this.adList = []
    //       for (var i = 0; i < res.data.data.length; i++) {
    //         let text = ''
    //         if (res.data.data[i].release_time) {
    //           text = res.data.data[i].title + '  ' + res.data.data[i].release_time
    //         } else {
    //           text = res.data.data[i].title
    //         }
    //         this.textArr.push(text)
    //       }
    //     } else {
    //       this.$Notice.error({ title: '获取公告列表失败', desc: res.data.errmsg })
    //     }
    //   })
    // },
    // findHtmlList () {
    //   findHtmlList({}).then(res => {
    //     if (res.data.errcode === 0) {
    //       if (res.data.data) {
    //         this.htmllist = res.data.data
    //         this.opennoticeDocument()
    //       }
    //     }
    //   })
    // },
    opennoticeDocument () {
      for (var i in this.htmllist) {
        let item = this.htmllist[i]
        if (item.isshow === '1') {
          this.display_model1_obj1.html = item.html
          this.display_model1_obj1.index_id = item.id
          this.display_model1_obj1.modal1 = true
          item.isshow = '0'
          this.countDown(item.showtime)
          return
        }
      }
    },
    // showkefu () {
    //   getHtml1({}).then(res => {
    //     if (res.data.errcode === 0) {
    //       this.modalDevice2html = res.data.data.html
    //     }
    //   })
    // },
    countDown (time) {
      this.time = time + 's'
      if (time === 0) {
        this.disabledCodeBtn = true
        this.time = ''
        return
      } else {
        this.disabledCodeBtn = false
        time--
      }
      setTimeout(() => {
        this.countDown(time)
      }, 1000)
    },
    savelogea () {
      let params = {
        index_id: this.display_model1_obj1.index_id
      }
      savelog(params).then(res => {})
      this.display_model1_obj1.modal1 = false
      setTimeout(() => {
        this.opennoticeDocument()
      }, 500)
    },
    cheakPassword () {
      // console.log('Gmk.password:' + Gmk.password)
      var value = Gmk.password
      if (!value) {
        return
      }
      var pwdRegex = new RegExp('(?=.*[0-9]).{8,30}')
      var pwdRegex1 = new RegExp('(?=.*[a-zA-Z]).{8,30}')
      var pwdRegex2 = new RegExp('(?=.*[^a-zA-Z0-9]).{8,30}')
      if (!pwdRegex.test(value)) {
        this.$Notice.error({ title: '您的密码复杂度太低（密码中必须包含数字），请及时修改密码！' })
        this.passwordInfo.show = true
      } else if (!pwdRegex1.test(value)) {
        this.$Notice.error({ title: '您的密码复杂度太低（密码中必须包含字母），请及时修改密码！' })
        // alert('您的密码复杂度太低（密码中必须包含字母），请及时修改密码！')
        this.passwordInfo.show = true
      } else if (!pwdRegex2.test(value)) {
        this.$Notice.error({ title: '您的密码复杂度太低（密码中必须包含特殊字符），请及时修改密码！' })
        this.passwordInfo.show = true
      }
      Gmk.password = ''
    }
  },
  watch: {
    '$route' (newRoute) {
      console.log(newRoute, 'watch新的路由变化')
      // console.log(this.menuList, '获取当菜单数据')
      let tempMenuList = this.menuList
      for (let key in tempMenuList) {
        let childData = tempMenuList[key].children
        if (tempMenuList[key].name && tempMenuList[key].name === newRoute.name) {
          console.log('ok11')
          newRoute.meta.title = tempMenuList[key].meta.title // 为了不在路由里面取名字写的循环
        } else {
          if (tempMenuList[key].children && tempMenuList[key].children.length > 0) {
            for (let k2 in childData) {
              let chid = childData[k2]
              if (chid.name === newRoute.name) {
                console.log('ok')
                newRoute.meta.title = chid.meta.title // 为了不在路由里面取名字写的循环
              }
            }
          }
        }
      }
      const { name, query, params, meta } = newRoute
      if (newRoute.meta.hide === true) {
        this.addTag({
          route: { name, query, params, meta },
          type: 'push'
        })
        this.setBreadCrumb(newRoute)
        this.tempTagNavList = []
        for (var i = 0; i < this.tagNavList.length; i++) {
          if (this.tagNavList[i].meta.hide === true) {
            this.tempTagNavList.push(this.tagNavList[i])
          }
        }
        this.setTagNavList(getNewTagList(this.tempTagNavList, newRoute))
      }
      // this.$refs.sideMenu.updateOpenName(newRoute.name)
    }
  },
  mounted () {
    const { name, params, query, meta } = this.$route
    this.addTag({
      route: { name, params, query, meta }
    })
    let severUserInfo = this.$store.state.user.severUserInfo
    this.loginCompanyType = severUserInfo.company_type
    this.device_code = severUserInfo.email
    this.company_codes = severUserInfo.company_code
    this.loginNames = severUserInfo.loginName
    this.personData.name = severUserInfo.name
    this.personData.company_name = severUserInfo.company_name
    // this.findHtmlList()
    // this.showkefu()
    // this.getNoticeList()
    this.login_url = this.login_url = window.location.href
    this.startMove()
    this.location_url = window.location.href
    this.mzMenulist()
    this.setTagNavList()
    this.setHomeRoute(routers)
    this.highMeter1 = severUserInfo.email
    // getCodeUrl(this.company_codes, this.loginNames).then(res => {
    //   this.codeUrl = res.data.result.url
    // })
    this.routeList = this.$store.state.app.mainv3Nav
    this.getTreeList()
    this.cheakPassword()
    // 管理账号和非管理账号的菜单过滤
    // this.permission_display()
    // 城市账号|农村账号|集中安置点账号 菜单过滤
    // this.loginCode_display()

    // this.timerInterval = setInterval(() => {
    //   getSeparateNotice().then(res => {
    //     res.data.data.forEach(element => {
    //       this.$Notice.close(element.id)
    //       this.$Notice.info({
    //         title: '您有新的收受分离事项！',
    //         duration: 0,
    //         name: element.id,
    //         render: h => {
    //           return h('span', [
    //             element.title,
    //             h('Button', {
    //               props: { type: 'primary', size: 'small' },
    //               style: { marginLeft: '10px' },
    //               on: {
    //                 click: () => {
    //                   this.setFlowSee(element.id)
    //                   this.toSeparate()
    //                   this.$Notice.close(element.id)
    //                 }
    //               }
    //             }, '查看')
    //           ])
    //         },
    //         onClose: () => {
    //           this.setFlowSee(element.id)
    //         }
    //       })
    //     })
    //   })
    //   // 页面获取收受分离信息30秒调一次
    // }, 30000)
  }
}
</script>
